/**
 * 
 */
package design_pattern.chainOfResponsibility;

/**
 * @author linzq
 * 
 */
public abstract class Player {

  protected Player successor;

  public abstract void handle();

  public Player(Player successor) {
    this.successor = successor;
  }

  public Player() {}

  public void play() {}

  public void next() {
    // 判断下家对象是否有效
    if (successor != null) {
      // 将请求传给下家
      successor.handle();
    } else {
      System.out.println("Program is terminating.");
      System.exit(0);
    }
  }

  public void setSuccessor(Player successor) {
    this.successor = successor;
  }
}
